package mil.af.amc.adpetracker.web.actions.AdpeAccount;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Action to allow ECs with more than one ADPE Account to change to a different one
 *
 * @author TSgt Jason Ferguson
 */

public class ChooseAccountAction extends Action {

    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

        int acctId = Integer.parseInt(request.getParameter("newAdpeAccountId"));
        request.getSession().setAttribute("accountId", acctId);
/*        DynaActionForm chooseAccountForm = (DynaActionForm) form;
        int accountId = (Integer) chooseAccountForm.get("accountId");*/



/*        Integer acctId = (Integer) request.getAttribute("newAdpeAccountId");
        if (acctId != null) {
            //int acctId = (Integer) request.getAttribute("newAdpeAccountId");
            request.setAttribute("newAdpeAccountId", acctId);
            request.getSession().setAttribute("accountId", acctId);
        }*/

        return mapping.findForward("viewAccountProfile");
    }

}
